package com.aps.api;

import com.aps.entity.dto.*;
import com.aps.service.IDishService;
import com.aps.service.IDishTypeSeqService;
import com.aps.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.aps.service.IApsOrderService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * @author liaoguangan
 * @description <>
 * @date 2018/4/1 18:31
 */
@RestController
@RequestMapping("/order-api")
@Api(value = "order-api", description = "POS订单相关接口")
public class OrderApi {

    @Autowired
    private IApsOrderService orderService;

    @Autowired
    private IDishService dishService;

    @Autowired
    private IStoreService storeService;

    @Autowired
    private IDishTypeSeqService dishTypeSeqService;

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation("POS下单接口")
    public void posSaveOrder(@RequestBody ApsOrderReqDTO apsOrderReqDTO) {
        orderService.save(apsOrderReqDTO);
    }

    @RequestMapping(value = "/change", method = RequestMethod.POST)
    @ApiOperation("POS订单变更接口")
    public void changeOrder(@RequestBody OrderChangeReqDTO orderChangeReqDTO) {
        orderService.change(orderChangeReqDTO);
    }

    @RequestMapping(value = "/syn-dish", method = RequestMethod.POST)
    @ApiOperation("POS同步菜品信息")
    public void synDish(@RequestBody List<PosSyncDish> posSyncDish) {
        dishService.save(posSyncDish);
    }

    @RequestMapping(value = "/syn-dish-type", method = RequestMethod.POST)
    @ApiOperation("POS同步菜品类别信息")
    public void synDishType(@RequestBody List<PosSyncDishType> posSyncDishType) {
        dishTypeSeqService.save(posSyncDishType);
    }

    @RequestMapping(value = "/syn-store", method = RequestMethod.POST)
    @ApiOperation("POS同步门店信息")
    public void synStore(@RequestBody List<PosSyncStore> posSyncStore) {
        storeService.save(posSyncStore);
    }

    @RequestMapping(value = "/schedule", method = RequestMethod.GET)
    @ApiOperation("排程测试")
    public void schedule() {
        orderService.schedule();
    }
}
